package com.fita.admin.entity.content;


import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;
import com.fita.entity.coupon.CouponStatus;

import java.util.Map;

/**
 * @author LZJ
 *
 */
public class CouponUseSearch implements QueryBuilder {

    /** 用户手机号 */
    private String mobile;

    /** 优惠券码 */
    private String code;

    private CouponStatus status;

    private QueryFilter filter;

    /**
     * default constructor
     */
    public CouponUseSearch() {
        
    }
    
    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {

        if(filter == null || refresh) {
            filter =  new QueryFilter().addLike("mobile", mobile)
                                  .addLike("code", code)
                                  .addEquals("status",status);
        }

        return filter;
    }
    
    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {
        return "FROM Coupon " + getPreparedFilter(false).whereSentence() ;
    }

    /*
     * (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {
        return getPreparedFilter(false).parameters();
    }


    public String getMobile() {
        return mobile;
    }

    public CouponUseSearch setMobile(String mobile) {
        this.mobile = mobile;
        return this;
    }

    public String getCode() {
        return code;
    }

    public CouponUseSearch setCode(String code) {
        this.code = code;
        return this;
    }

    public CouponStatus getStatus() {
        return status;
    }

    public CouponUseSearch setStatus(CouponStatus status) {
        this.status = status;
        return this;
    }

    @Override
	public QueryOrder getOrder() {
		// TODO Auto-generated method stub
		return null;
	}

  

}